﻿Imports System.Data.OleDb
Public Class KhoaDAO
    Public Shared Function SelectAll() As DataTable
        Dim strSQL As String = "select * from Khoa"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub Insert(ByVal _khoa As KhoaDTO)
        Dim strSQL As String = "Insert into Khoa(MaKhoa,TenKhoa,Diengiai)  Values('" & _khoa.Makhoa & "',N'" & _khoa.Tenkhoa & "',N'" & _khoa.Diengiai & "')"
        SQLProvider.ExecNoneQuery(strSQL)

    End Sub
    Public Shared Sub Delete(ByVal _khoa As KhoaDTO)
        Dim strSQL As String = "delete from Khoa where MaKhoa = '" & _khoa.MaKhoa & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Sub Update(ByVal _khoa As KhoaDTO)
        Dim strSQL As String = "Update Khoa set TenKhoa = N'" & _khoa.Tenkhoa & "', Diengiai = N'" & _khoa.Diengiai & "' where MaKhoa = '" & _khoa.Makhoa & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function SelectByKhoa(ByVal _khoa As KhoaDTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from Khoa where TenKhoa like N'%" & _khoa.Tenkhoa & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
End Class
